package cn.smile.controller.wechat;

import cn.smile.bean.dto.wechat.WechatDevelopConfigDTO;
import cn.smile.bean.form.wechat.develop.SaveDevConfigForm;
import cn.smile.business.wechat.IWeChatDevConService;
import cn.smile.commons.response.MyResult;
import cn.smile.utils.UserUtil;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/weChatDev")
public class WeChatDevConController {
    @Resource
    private IWeChatDevConService service;

    @PostMapping(value = "saveConfig")
    public MyResult<Boolean> saveConfig(@Valid @RequestBody SaveDevConfigForm form) {
        return MyResult.OK(service.saveConfig(form));
    }

    @GetMapping(value = "getMyConfig")
    public MyResult<WechatDevelopConfigDTO> getMyConfig() {
        return MyResult.OK(service.getConfigByUser(UserUtil.getUserInfo().getId()));
    }

    @GetMapping(value = "getMyConfigStatus")
    public MyResult<Boolean> getMyConfigStatus() {
        return MyResult.OK(service.getMyConfigStatus());
    }
}
